<template>
    <div class="echart-chart">
        <div class="inside">
            <header><i class="el-icon-location-outline"></i> 租售比</header>
            <div class="chartBox clearfix" style="min-height: 100px;">
                <aside v-show="!chartNoDataShow">
                    <!--<p>？——be_prop_count：{{ isNull0(be_prop_count) }}</p>-->
                    <!--<p>？——sample_rate：{{ isNull0(sample_rate) }}</p>-->
                    <!--<p>？——med_be：{{ isNull0(med_be) }}</p>-->
                    <p>？——brea_keven：{{ isNull0(brea_keven) }}</p>
                    <p>中位租售比：{{ isNull0(med_pr) }}</p>
                </aside>
                <h4 ref="BreakEven_PR_NoData" v-show="chartNoDataShow"></h4>
            </div>
            <p v-show="false">{{getzipcode}}</p>

        </div>
    </div>
</template>

<script>
    export default {
        data() {
            return {
                chartNoDataShow: false, //判断是否有无数据
                be_prop_count: '', //
                sample_rate: '', //
                med_be: '', //
                brea_keven: '', //含义zillow还没回复，值为年月
                med_pr: '', //中位租售比，值为年月

            }
        },
        computed: {
            //房源详情页图表使用——本房源所在邮zipcode
            getzipcode() {
                if(this.$store.getters.get_houseDetailsZipcode){
                    //获取租售比数据
                    this.get_BreakEven_PR();
                }
                return this.$store.getters.get_houseDetailsZipcode
            }
        },
        created() {
        },
        mounted() {
        },
        methods: {
            //获取租售比数据
            get_BreakEven_PR() {
                this.$get('/analysis/sale_rental_ratio/85/'+ this.$store.getters.get_houseDetailsZipcode).then(res => {
                    if (res.status == 0) {
                        if(res.data != null){
                            this.chartNoDataShow = false;
                            this.be_prop_count = res.data.be_prop_count;
                            this.sample_rate = res.data.sample_rate;
                            this.med_be = res.data.med_be;

                            //含义zillow还没回复，值为年月
                            let brea_keven_year = res.data.brea_keven.replace(' year(s)', '年');
                            let brea_keven_month = brea_keven_year.replace(' month(s)', '个月');
                            let brea_keven_year_month = brea_keven_month.replace(' and ', '');
                            this.brea_keven = brea_keven_year_month;

                            //中位租售比，也就是中位房价除以年中位租金，假如值为41.94，那么展示结果为：年和月。用0.94乘以12个月，也就是11.06。41.94代表41年11个月。
                            let med_pr_year = parseInt(res.data.med_pr.toString().split('.')[0]);
                            let med_pr_month = parseFloat('0.' + Math.round(parseFloat( '0.' + res.data.med_pr.toString().split('.')[1]) * 12));
                            this.med_pr = med_pr_year + med_pr_month;
                        }else{
                            this.chartNoDataShow = true;
                            this.$refs.BreakEven_PR_NoData.innerText = '暂未查询到数据！';
                        }
                    } else {
                        this.chartNoDataShow = true;
                        this.$refs.BreakEven_PR_NoData.innerText = res.msg;
                    }
                });
            },
        },
        components: {}
    }
</script>

<style scoped lang="less" type="text/less">
</style>
